<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<style type="text/css">
ul.rightTools {
	float: right;
	display: block;
}

ul.rightTools li {
	float: left;
	display: block;
	margin-left: 5px
}
</style>
<script type="text/javascript">
<!--
	var customergridIdString = "#combinecustomerInfolist";
	var licensegridIdString = "#combinelicenseInfolist";
	jQuery(document)
			.ready(
					function() {
						customerGrid = jQuery(customergridIdString);
						customerGrid
								.jqGrid({
									url : "customerInfoGrid",
									datatype : "json",
									mtype : "GET",
									colModel : [
											{
												name : 'customerInfoId',
												index : 'customerInfoId',
												align : 'center',
												label : '<s:text name="customerInfo.customerInfoId" />',
												hidden : true,
												key : true
											},
											{
												name : 'customerName',
												index : 'customerName',
												align : 'center',
												label : '<s:text name="customerInfo.customerName" />',
												width : 50

											} ],

									jsonReader : {
										root : "pageList", // (2)
										page : "page",
										total : "total",
										records : "records", // (3)
										repeatitems : false
									},

									prmNames : {
										page : "page",
										rows : "pagesize",
										sort : "sortname",
										order : "sortorder"
									},
									rowNum : 10,
									rowList : [ 5, 10, 20, 50, 100, 200 ],
									pager : '#combinecustomerInfopager',
									rownumbers : false,
									sortname : 'customerInfoId',
									sortorder : 'desc',
									//caption : '<s:text name="customerInfoList.title" />',
									height : "500",
									autowidth : true,
									loadui : "disable",
									multiselect : false,
									multiboxonly : true,
									hidegrid : false,
									onSelectRow : function(rowid) {

										var sid = jQuery(this).jqGrid(
												'getGridParam', 'selrow');
										if (!sid) {

										} else {
											var urlString = "licenseInfoGrid";
											urlString = urlString
													+ "?customerId=" + sid;
											$(licensegridIdString).jqGrid('setGridParam', {
												url : urlString,
												page : 1
											}).trigger("reloadGrid");
										}

									},
									gridComplete : function() {
										/* if (jQuery(this).getDataIDs().length > 0) {
											jQuery(this)
													.jqGrid(
															'setSelection',
															jQuery(this)
																	.getDataIDs()[0]);//默认选中第一行
										} */
									},
									loadComplete : function(data) {
										//resizeJqGrid($(this));
										resizeJqGrid($(this));
										if (data.ajaxStatus === "error")
											alertMsg.error(data.ajaxMessage);

									},
									loadError : function(xhr, st, err) {
										alertMsg.error("Type: " + st
												+ "; Response: " + xhr.status
												+ " " + xhr.statusText);
									}

								});

						 	jQuery(customerGrid).jqGrid('navGrid',
									'#combinecustomerInfopager', {
										edit : false,
										add : false,
										del : false,
										search : false,
										excel : false
									}, {}, {}, {}, {
										multipleSearch : false,
										multipleGroup : false
									});

						/* $("#combinecustomerInfolistId").bind(
								"resize",
								function() {
									resizeGrid($("#combinecustomerInfolist"),
											0, "#combinecustomerInfolistId");
								}); */

						licenseGrid = jQuery(licensegridIdString);
						licenseGrid
								.jqGrid({
									url : "licenseInfoGrid",
									datatype : "json",
									mtype : "GET",
									colModel : [
											{
												name : 'licenseInfoId',
												index : 'licenseInfoId',
												align : 'center',
												label : '<s:text name="licenseInfo.licenseInfoId" />',
												hidden : false,
												key : true,
												width : 50
											},
											{
												name : 'customerInfo.customerName',
												index : 'customerInfo.customerName',
												align : 'center',
												label : '<s:text name="customerInfo.customerName" />',
												width : 50

											},
											{
												name : 'genDate',
												index : 'genDate',
												align : 'center',
												label : '<s:text name="licenseInfo.genDate" />',
												width : 50,
												formatter:'date',
												formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'Y-m-d H:i:s'}
												//datefmt:'Y-m-d H:i:s'


											},
											{
												name : 'licenseDefineData',
												index : 'licenseDefineData',
												align : 'center',
												label : '<s:text name="licenseInfo.licenseDefineData" />',
												width : 100

											},
											{
												name : 'currentUsed',
												index : 'currentUsed',
												align : 'center',
												label : '<s:text name="licenseInfo.currentUsed" />',
												width : 50,
												formatter :"checkbox"

											},
											{
												name : 'note',
												index : 'note',
												align : 'center',
												label : '<s:text name="licenseInfo.note" />',
												width : 100

											}  ],

									jsonReader : {
										root : "pageList", // (2)
										page : "page",
										total : "total",
										records : "records", // (3)
										repeatitems : false
									},

									prmNames : {
										page : "page",
										rows : "pagesize",
										sort : "sortname",
										order : "sortorder"
									},
									rowNum : 10,
									rowList : [ 5, 10, 20, 50, 100, 200 ],
									pager : '#combinelicenseInfopager',
									rownumbers : false,
									sortname : 'licenseInfoId',
									sortorder : 'desc',
									//caption : '<s:text name="licenseInfoList.title" />',
									height : "500",
									//width:"800",
									autowidth : false,
									loadui : "disable",
									multiselect : true,
									multiboxonly : true,
									hidegrid : false,
									gridComplete : function() {
										if (jQuery(this).getDataIDs().length > 0) {
											jQuery(this)
													.jqGrid(
															'setSelection',
															jQuery(this)
																	.getDataIDs()[0]);//默认选中第一行
										}
									},
									loadComplete : function(data) {
										resizeJqGrid($(this));
										if (data.ajaxStatus === "error")
											alertMsg.error(data.ajaxMessage);

									},
									loadError : function(xhr, st, err) {
										/* alertMsg.error("Type: " + st
												+ "; Response: " + xhr.status
												+ " " + xhr.statusText); */
									}

								});
						jQuery(licenseGrid).jqGrid('navGrid',
								'#combinelicenseInfopager', {
									edit : false,
									add : false,
									del : false,
									search : false,
									excel : false
								}, {}, {}, {}, {
									multipleSearch : false,
									multipleGroup : false
								});
					});

	function addNewLicense(){

		var sid = $(customergridIdString).jqGrid('getGridParam','selrow');
		var url = "addNewLicense?customerId="+sid;
		var winTitle='新建许可证';
		url = encodeURI(url);
		//$.navTab.open(url, 'addNewLicense', winTitle, {mask:false,width:880,height:600});　
		navTab.openTab("navTabAddNewLicense", url, { title:winTitle, fresh:true, data:{} });
	}

	function watchLicense(){

		var sid = $(licensegridIdString).jqGrid('getGridParam','selrow');
		var eurl = "watchLicense?licenseInfoId="+sid;
		var winTitle = "查看生产许可详细信息";
		eurl = encodeURI(eurl);


		$.pdialog.open(eurl, 'watchLicense', winTitle, {mask:true,width:880,height:600});　

	}
	function watchDogLicense(){
		//var sid = $(licensegridIdString).jqGrid('getGridParam','selrow');
		var eurl = "watchDogLicense";
		var winTitle = "查看硬件狗内许可详细信息";
		eurl = encodeURI(eurl);
		$.pdialog.open(eurl, 'watchDogLicense', winTitle, {mask:true,width:880,height:600});　

	}
	function updateLicense(){
		var sid = $(licensegridIdString).jqGrid('getGridParam','selrow');
		var eurl = "updateLicense?licenseInfoId="+sid;
		var winTitle = "查看硬件狗内许可详细信息";
		eurl = encodeURI(eurl);
		//$.pdialog.open(eurl, 'watchDogLicense', winTitle, {mask:true,width:880,height:600});　

		jQuery
		.ajax({
			dataType : 'json',
			url : eurl,
			//data : 'allParam=' + entityArray,
			type : 'POST',
			async : 'false',
			error : function(data) {
				//alert(data);
				/* alertMsg
						.confirm("编辑保存失败,有可能是由于编辑内容过多,请尝试每页条数在100以内！！！"); */
				alertMsg.error(data.ajaxMessage)
			},
			success : function(data) {
				if(data.ajaxStatus=='error')
					alertMsg.error(data.ajaxMessage);
					else
					alertMsg.correct(data.ajaxMessage);
			}
		});


	}
	
	function updateCurrent(){
		//var cid = $(customergridIdString).jqGrid('getGridParam','selrow');
		var lid = $(licensegridIdString).jqGrid('getGridParam','selrow');
		var eurl = "updateCurrent?licenseInfoId="+lid;
		var winTitle = "查看硬件狗内许可详细信息";
		jQuery
		.ajax({
			dataType : 'json',
			url : eurl,
			//data : 'allParam=' + entityArray,
			type : 'POST',
			async : 'false',
			error : function(data) {
				//alert(data);
				/* alertMsg
						.confirm("编辑保存失败,有可能是由于编辑内容过多,请尝试每页条数在100以内！！！"); */
				alertMsg.error(data.ajaxMessage)
			},
			success : function(data) {
				if(data.ajaxStatus=='error')
					alertMsg.error(data.ajaxMessage);
					else
					alertMsg.correct(data.ajaxMessage);
			}
		});
	}
	function deleteLicenses(){
		var cid = $(customergridIdString).jqGrid('getGridParam','selrow');
		var lid = $(licensegridIdString).jqGrid('getGridParam','selarrrow');
		var eurl = "deleteLicense?licenseIds="+lid+"&customerId="+cid;
		jQuery
		.ajax({
			dataType : 'json',
			url : eurl,
			type : 'POST',
			async : 'false',
			error : function(data) {

				alertMsg.error(data.ajaxMessage)
			},
			success : function(data) {
				if(data.ajaxStatus=='error')
					alertMsg.error(data.ajaxMessage);
					else
					alertMsg.correct(data.ajaxMessage);
			}
		});
		
		
	}
	
	function outputLicenseV2C(){
		var lid = $(licensegridIdString).jqGrid('getGridParam','selrow');
		var url = "${ctx}/outputLicenseV2C?licenseInfoId="+lid;
		url=encodeURI(url);
		location.href=url; 
	}
//-->
</script>



<div class="pageContent" style="padding: 1px">

	<div class="tabs">
		<!-- <div class="tabsHeader">
			<div class="tabsHeaderContent">
				<ul>
					<li><a href="javascript:;"><span>实验室检测</span></a></li>

				</ul>
			</div>
		</div> -->
		<div class="tabsContent">
			<div>

				<div id="combinecustomerInfolistId"  class="pageContent" layoutH="20"
					style="width:30%;float: left; display: block; overflow:hidden;  border: solid 1px #CCC; line-height: 21px; background: #fff" >
					<div class="panelBar">
						<ul class="toolBar">
							<!-- <li><a class="add" href="#"
								onclick="javaScript:addProductInfo();"><span>添加</span></a></li>
							<li class="line">line</li>
							<li><a class="delete" href="#"
								onclick="javaScript:processGridSelectedRecords('productInfolist','deleteProductInfo','确认删除吗?');"><span>删除</span></a></li>
							<li class="line">line</li>
							<li><a class="edit" href="#"
								onclick="javaScript:editProductInfo();"><span>修改</span></a></li>
							<li class="line">line</li>
							<li><a class="icon" href="#"
								onclick="javaScript:processGridSelectedRecords('productInfolist','disableProductInfo','确认停用吗?');"><span>停用</span></a></li>
							<li class="line">line</li>
							<li><a class="icon" href="#"
								onclick="javaScript:processGridSelectedRecords('productInfolist','enableProductInfo','确认启用吗?');"><span>启用</span></a></li> -->
						</ul>
					</div>
					<table id="combinecustomerInfolist"></table>
					<div id="combinecustomerInfopager"></div>
				</div>
				<div id="combinelicenseInfolistId"  class="pageContent" layoutH="20"
					style="width:69%;float: left; display: block; overflow:hidden; border: solid 1px #CCC; line-height: 21px; background: #fff; margin-left: 5px;">
					<div class="panelBar">
						<ul class="toolBar">
							<li><a class="add" href="#"
								onclick="javaScript:addNewLicense();"><span>新建License</span></a></li>
							 <li class="line">line</li>
							<li><a class="add" href="#"
								onclick="javaScript:updateCurrent();"><span>设置当前使用License</span></a></li>
							 <li class="line">line</li>
							<li><a class="add" href="#"
								onclick="javaScript:deleteLicenses();"><span>删除License</span></a></li>
							 <li class="line">line</li>
							<li><a class="add" href="#"
								onclick="javaScript:watchLicense();"><span>查看License</span></a></li>
							 <li class="line">line</li>
							<li><a class="add" href="#"
								onclick="javaScript:watchDogLicense();"><span>查看Dog内信息</span></a></li>
							 <li class="line">line</li>
							<li><a class="add" href="#"
								onclick="javaScript:updateLicense();"><span>烧制狗</span></a></li>
							 <li class="line">line</li>
							<li><a class="add" href="#"
								onclick="javaScript:outputLicenseV2C();"><span>导出License文件</span></a></li>
							 <!--<li class="line">line</li>
							<li><a class="delete" href="#"
								onclick="javaScript:processGridSelectedRecords('productInfolist','deleteProductInfo','确认删除吗?');"><span>删除</span></a></li>
							<li class="line">line</li>
							<li><a class="edit" href="#"
								onclick="javaScript:editProductInfo();"><span>修改</span></a></li>
							<li class="line">line</li>
							<li><a class="icon" href="#"
								onclick="javaScript:processGridSelectedRecords('productInfolist','disableProductInfo','确认停用吗?');"><span>停用</span></a></li>
							<li class="line">line</li>
							<li><a class="icon" href="#"
								onclick="javaScript:processGridSelectedRecords('productInfolist','enableProductInfo','确认启用吗?');"><span>启用</span></a></li>
 -->						</ul>
					</div>
					<table id="combinelicenseInfolist"></table>
					<div id="combinelicenseInfopager"></div>
				</div>


			</div>


		</div>
		<div class="tabsFooter">
			<div class="tabsFooterContent"></div>
		</div>
	</div>

</div>




